<form [formGroup]="form">
  <div formArrayName="dimens" *ngFor="let unit of formData.controls; let i=index">
    <mat-divider *ngIf="formData.controls.length > 1 && i > 0"></mat-divider>
    <br>
    <div [formGroupName]="i">
      <button type="button" mat-mini-fab color="warn"
              *ngIf="form.controls.dimens.controls.length > 1"
              (click)="removeUnit(i)">
        删除
      </button>

      <mat-form-field>
        <input matInput placeholder="标题" formControlName="title" required>
      </mat-form-field>

      <span formArrayName="items" *ngFor="let subUnit of getSubFormData(i).controls; let j=index">
            <span [formGroupName]="j">
              <mat-form-field>
                <input matInput placeholder="Content" formControlName="content" required>
              </mat-form-field>

              <button mat-mini-fab color="warn" type="button" color="primary"
                      *ngIf="getContentItemFormArray(i).controls && getContentItemFormArray(i).controls.length > 1"
                      (click)="removeSubUnit(i, j)">
                删除
              </button>
            </span>
          </span>

      <button mat-mini-fab color="warn" type="button" color="primary" (click)="addSubUnit(i)">
        <mat-icon>add box</mat-icon>
      </button>
    </div>
  </div>
</form>

<div>
  <button mat-button matStepperPrevious>Back</button>
  <button mat-button matStepperNext (click)="submitBackgroundForm()">Next</button>
</div>
